﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IPC.Communication.Framework.ModBus;

namespace IPC.Communication.Framework.Profinet.Inovance
{
    public class InovanceTcpNet : ModbusTcpNet
    {
        public InovanceSeries Series
        {
            get;
            set;
        }

        public InovanceTcpNet()
        {
            Series = InovanceSeries.AM;
        }

        public InovanceTcpNet(string ipAddress, int port = 502, byte station = 1)
            : base(ipAddress, port, station)
        {
            Series = InovanceSeries.AM;
        }

        public InovanceTcpNet(InovanceSeries series, string ipAddress, int port = 502, byte station = 1)
            : base(ipAddress, port, station)
        {
            Series = series;
        }

        public override OperateResult<string> TranslateToModbusAddress(string address, byte modbusCode)
        {
            return InovanceHelper.PraseInovanceAddress(Series, address, modbusCode);
        }

        public override string ToString()
        {
            return String.Format("InovanceTcpNet<{0}>[{1}:{2}]", Series, IpAddress, Port);
        }
    }
}